{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "APP激活码由大小写的字母和数字随机组成，不同的APP激活码位数应该是一样的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "ls=[]\n",
    "for x in range(65,91):\n",
    "    a=str(chr(x))\n",
    "    ls.append(a)\n",
    "for x in range(97,123):\n",
    "    a=str(chr(x))\n",
    "    ls.append(a)\n",
    "for x in range(10):\n",
    "    a=str(x)\n",
    "    ls.append(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "将字母大小写和数字以字符的形式存放在列表ls里面"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def getCode(n=6):\n",
    "    s=''\n",
    "    for i in range(n):\n",
    "        a=random.choice(ls)\n",
    "        s=s+a\n",
    "    print(s)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义函数，随机从ls列表里面取元素，取n次存放到s中"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入需要生成的激活码个数200\n",
      "请输入需要生成的激活码的位数10\n",
      "CWPsRslXVe\n",
      "eP9QiJM6dC\n",
      "YpuYtv5Zz1\n",
      "QG2MwWHJXi\n",
      "hF6x0Matks\n",
      "qqoG5zzAHM\n",
      "VfY7w6Bs33\n",
      "2hbD2faOU8\n",
      "LshPYfYb8k\n",
      "yfVniROWCm\n",
      "KWflcUa1Or\n",
      "xSnpNiRgS5\n",
      "mZSQCYVmPh\n",
      "qvyn7i1bAH\n",
      "vAv182ZwFu\n",
      "IqbMzfzcn5\n",
      "meNzPb56QI\n",
      "W8R0nVRRly\n",
      "Hjawydp13O\n",
      "M3jvQpBTWq\n",
      "xyQN7GohIx\n",
      "790Ss6DmQE\n",
      "JtD56DRFV5\n",
      "msPsVPDmru\n",
      "9sx3Z8bQ7q\n",
      "7Coou291bf\n",
      "oYrU03t5fo\n",
      "mk9rbPGqX4\n",
      "XbRlzLu7lI\n",
      "gIVKDkazWv\n",
      "8kGCBNnRzB\n",
      "XJcx4XRpPl\n",
      "XMzWyHzZsO\n",
      "FEzAhzbODt\n",
      "S0kA8rg2N4\n",
      "NBTJWMfMHA\n",
      "eC525g1c4j\n",
      "jfZ2mbLNwN\n",
      "S8TdgDETuZ\n",
      "DMiV6ibfyT\n",
      "SoiHA47SQw\n",
      "SricGuCqIT\n",
      "ZLqD4hR41P\n",
      "R8cvfkZ3ZD\n",
      "BTCVUPIIgp\n",
      "TUIxBv22an\n",
      "vNwCkjvLco\n",
      "Zjnjw71AVa\n",
      "9fLAcuBiyL\n",
      "2UZfBgVEyF\n",
      "0x9OZI8v85\n",
      "zgK5qwgmCm\n",
      "vPnE8TsRGb\n",
      "lGyQRGGIUd\n",
      "js5PjEJEzG\n",
      "EEjxc7K3ZI\n",
      "FKwhX56viR\n",
      "zBO5spWWza\n",
      "XPkM4wN9gt\n",
      "qlWKlRKiE6\n",
      "ZNyVbDA5vw\n",
      "Ujw7pfkqc8\n",
      "tPiqC88RDy\n",
      "lYkeQOTorA\n",
      "c1w8yhCQS6\n",
      "CWskPHn3tT\n",
      "6wZ6FOhuDF\n",
      "oxOLQHbNJl\n",
      "TkmcoAdHj1\n",
      "dbP9hEfgnk\n",
      "cizQH2VVky\n",
      "WB4FFu2Uwb\n",
      "C7HmYN7W7R\n",
      "OdMy1h6bxR\n",
      "4slgbPYFr8\n",
      "XiGc9euVEy\n",
      "qI425JiCMs\n",
      "Fw3cmv0dXk\n",
      "e9lFAuuydN\n",
      "IFP8jBcXkr\n",
      "B5I4Hd0C07\n",
      "9Fnm0kPaBd\n",
      "fa4A47fC93\n",
      "YpwEIxzgHG\n",
      "VuyLasSmEn\n",
      "6fsFY7L0hZ\n",
      "3wVBPE7ckG\n",
      "WrzpjNE8sA\n",
      "fZ203x8Ljr\n",
      "XuanSRE2L7\n",
      "UxkX5SijKH\n",
      "sklbWYZiaw\n",
      "ALocN3UzB9\n",
      "K8PjX8Ti5K\n",
      "fnuSQtt0pj\n",
      "y5twbjalCL\n",
      "YtKAS8X0k0\n",
      "x5KBKoFm4f\n",
      "u55xFUQXju\n",
      "4RimfAyGNi\n",
      "KyAr4Zl4uL\n",
      "rWz3IIa2SH\n",
      "iMSxHuC3Vf\n",
      "qc5c7auiW8\n",
      "KS24Qh5E9j\n",
      "TfifJaqIPZ\n",
      "BpAc6nbqQT\n",
      "wuJhAuf8un\n",
      "eiUbl6EzUG\n",
      "nXdqDRfa29\n",
      "IAnCBD4Bye\n",
      "9RpDlsyile\n",
      "KIxbJ18tYp\n",
      "JBr167VAdC\n",
      "oLRTlNM8Nt\n",
      "SEK0evrayo\n",
      "8sJbFu2Ay7\n",
      "vmeTX9Widl\n",
      "DQNghnCTgS\n",
      "DyBMd92urS\n",
      "GDlcZYd92j\n",
      "1FzoR6A1rJ\n",
      "KkZuasRF5l\n",
      "Unx6rvoCJO\n",
      "b6w17wYiUH\n",
      "bLN90pI65W\n",
      "aWVDrQMRpN\n",
      "Ex7VahNroV\n",
      "wYTLB5ZlrZ\n",
      "HUHrzaO67w\n",
      "7QcpEFEMvO\n",
      "hwFd2l5PBI\n",
      "oXU8Gp4ioi\n",
      "adBYgXbzNe\n",
      "dvjnsTH6qx\n",
      "SvyiQfUV3I\n",
      "bNdtxpYB4w\n",
      "MT38bitSak\n",
      "IsauHp7IET\n",
      "qKDfJs92PJ\n",
      "YOqAqDv8Hr\n",
      "0T4UobfPbV\n",
      "mHseqdwrAh\n",
      "7aJN49G1aD\n",
      "WyvYGqspc9\n",
      "0penj28oIt\n",
      "HNIYjbBCpf\n",
      "A6YBrg0kdt\n",
      "ofP3llKd1y\n",
      "yf2qXj2yj4\n",
      "7c282RIOvH\n",
      "61rU7wDCnV\n",
      "KAnIIOhMNw\n",
      "3IJc5nA9mD\n",
      "OJtz1dw7z6\n",
      "Lb3UUxjnsg\n",
      "GtdzrM0mwR\n",
      "cC4XolMJGW\n",
      "9sMnDkV70T\n",
      "DswtJ5BYFy\n",
      "NwUUgKZg1p\n",
      "f98IiFyivk\n",
      "N5fWkZwjiN\n",
      "9DzfeUBc44\n",
      "xqo54UEAij\n",
      "te8UX0T7ei\n",
      "k2UzuGHnGW\n",
      "7Ulb2YSXlW\n",
      "liXWjtjtuD\n",
      "QIXYzrtyDK\n",
      "wUuRlGvvNc\n",
      "WQlYBeoVIR\n",
      "o1QaeJ5CB5\n",
      "KWg0OjvgLv\n",
      "fy3Wwf4pPT\n",
      "XwFyEeSsLK\n",
      "MiujXLnBX2\n",
      "TEhhHpbdws\n",
      "WRFyJiSU1a\n",
      "lurtJ1dscL\n",
      "cuuvUsIelv\n",
      "lsdCLNCFUp\n",
      "OyYqIThepY\n",
      "8H9Ta1L0MA\n",
      "HomvAcVnwa\n",
      "1nXum1YRdA\n",
      "XglPHJyKiV\n",
      "1fdhwf9BZ4\n",
      "suwdbKNJK0\n",
      "ijg6igo1nT\n",
      "2T84Cshqfe\n",
      "xU1b7ptgGb\n",
      "UsM3ELAs8u\n",
      "QHwFMjLJMq\n",
      "rnCMVCPCx5\n",
      "30nvJ1BpHV\n",
      "WDuwo6rJt6\n",
      "GL8spdB7tK\n",
      "SxsE2YGZSC\n",
      "0c4kO9ygzi\n"
     ]
    }
   ],
   "source": [
    "amount=int(input(\"输入需要生成的激活码个数\"))\n",
    "n=int(input(\"请输入需要生成的激活码的位数\"))\n",
    "for i in range(amount):\n",
    "    getCode(n)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
